{include file="public/_meta" /}
{include file="public/_nav" /}

<div class="container body">
    <div class="col-xs-2">
        {include file="public/_left" /}
    </div>
    <div class="col-xs-10">
        <ol class="breadcrumb">
            导航位置：<li><a href="#">会员列表</a></li>
        </ol>
        <h2>会员列表<small>{if $usersInfo->total()}共计{$usersInfo->total()}条{else /}无数据{/if}</small></h2>
        <table class="table table-hover table-responsive table-striped table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>会员名称</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="usersInfo" id="vo"}
            <tr>
                <td>{$vo.id}</td>
                <td>{$vo.username}</td>
                <td>
                    <a href="{:url('admin/home/useredit', ['id' => $vo.id])}" class="btn btn-primary btn-xs">编辑</a>
                    <button class="btn btn-danger btn-xs userdel" _id="{$vo.id}">删除</button>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <nav class="text-center">
            {$usersInfo->render()|raw}
        </nav>
    </div>
</div>

{include file="public/_js" /}
<script>
    $('.userdel').click(function () {
        var id = $(this).attr('_id');
        layer.confirm('确定要删除吗？', {
            title:'删除会员',
            skin:'layui-layer-lan',
            icon:3,
            anim:6
        }, function (index) {
            $.ajax({
                url:"{:url('admin/home/userdel')}",
                type:'post',
                data:{id:id},
                dataType:'json',
                success:function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            icon:6,
                            time:2000
                        }, function () {
                            location.href = data.url;
                        });
                    }else {
                        layer.open({
                            title:'删除会员失败',
                            content:data.msg,
                            skin:'layui-layer-lan',
                            icon:5,
                            anim:6
                        });
                    }
                }
            });
            layer.close(index);
        });
        return false;
    });
</script>
</body>
</html>